Edge-Based Smart Irrigation System for Precision Agriculture

Maharudra, Design and Manufacturing, maharudrar@iisc.ac.in

Nikhil N S, Design and Manufacturing, nikhilns@iisc.ac.in

Surya Tomar, Design and Manufacturing, suryatomar@iisc.ac.in

Pandarasamy Arjunan, RBCCPS, samy@iisc.ac.in

Overview:

The Edge AI Precision Irrigation System is a fully autonomous, on-device solution for dynamically adjusting water supply to nursery-stage crops (e.g. onion seedlings) in response to environmental and crop conditions. It integrates historical climate data and real-time soil moisture sensing into a machine learning inference engine running on a microcontroller, which computes the crop’s current water demand and controls a pump actuation without cloud reliance. In our implementation, weather inputs (Tmax, RH, Irradiation) by weather API feed an MLP-based model on a Raspberry Pi Pico W to estimate daily reference evapotranspiration (ET₀) and then derive actual crop evapotranspiration (ET₀×Kc). This computed water requirement is used by the Pico to set the irrigation volume, and an ESP32 node drives a water pump via MQTT for the calculated duration.

Image 0

Background and Motivation:

Conventional irrigation often over-waters or follows rigid schedules, wasting water and harming crops. Onion seedlings are especially vulnerable early over-watering disrupts root aeration and yield, while uneven watering or waterlogging leads to soil salinity and nutrient loss. In water-scarce regions, these issues are severe. An intelligent, edge-based system can adjust irrigation to a crop’s growth stage, weather, and soil moisture without cloud dependency. By predicting reference ET₀ and applying the appropriate onion-specific Kc, our system delivers precisely the water each growth stage demands.

Image 1

Data Collection:

Historical climate data: We retrieved 34 years of daily weather records from NASA’s POWER API. The variables include daily minimum and maximum temperature (T₂M_min, T₂M_max), 2m relative humidity (RH₂m), 2m wind speed (WS₂m), and solar radiation (ALLSKY_SFC_SW_DWN). NASA POWER provides globally gridded, analysis-ready meteorological data via an API, making it suitable for our climate-based ET₀ modelling.

Label generation (ET₀): Using the FAO-56 Penman–Monteith formula (Allen et al., 1998), we computed the reference evapotranspiration (ET₀) for each day in the dataset. These ET₀ values serve as the labels for supervised model training. In other words, each weather record is paired with the FAO-56 ET₀ as the prediction target.

Real-time sensor data: In the field, a resistive analog soil moisture sensor is placed in each nursery pot or bed. This sensor outputs voltage proportional to volumetric water content (VWC), which we convert to an available water depth. The sensor data are fed continuously to the edge controller. This ensures that irrigation decisions account for current soil moisture, preventing overwatering if recent rain or irrigation already wetted the soil.

Preprocessing & Feature Engineering

Model Design and Training:

Model Selection: Benchmarked multiple regressors (linear, SVR, random forest); selected a feedforward MLP regressor for highest accuracy (~97% explained variance on test data).

Architecture: Two hidden layers with 16 and 8 neurons respectively; ReLU activations; optimized via Adam.

Training Configuration:

Dataset: ~5,569 samples (80% training / 20% testing)

Early stopping after 1,500 iterations when validation loss plateaued

Image 2

Performance:

Mean Squared Error (MSE) ≈ 0.03

R² ≈ 0.971 (≈97% variance explained)

Methodology:

ET₀ Prediction: Each day (or on-demand), the system gathers the current weather parameters using weather API (T_max, RH, solar radiation) and inputs them to the MLP model running on the Pico. The model outputs the predicted reference evapotranspiration ET₀ (mm/day).

Crop Water Demand (ETc): The predicted ET₀ is multiplied by a crop coefficient Kc corresponding to the crop growth stage. The product ETc = ET₀× Kc represents the actual crop evapotranspiration (mm/day), i.e. the water needed by the crop per day.

Soil Moisture Update: Concurrently, the soil moisture sensor provides the current volumetric water content (VWC) of the soil. This reading is converted to an “Available Water Depth” (depth of water the soil can hold above wilting point). If the soil is already near saturation (e.g. recent rain or irrigation), the system can reduce or skip watering.

Image 3

Irrigation Volume Calculation: A rule-based or proportional controller fuses ETc and soil moisture to compute the irrigation volume needed. Essentially, if available soil moisture is below target, the system delivers extra water equal to (ETc – soil depletion) for the period. This ensures the crop receives its required water deficit.

Pump Actuation: The Pico sends a command via MQTT to an ESP32 microcontroller connected to a relay and pump. The ESP32 then energizes the pump for the computed time, delivering the precise water volume. All pumping is timed so that the intended volume (mm of water over the crop area) is applied. This closed-loop process repeats at 24hr intervals or on demand, maintaining optimal moisture for the seedlings

Hardware and Software Stack:

Image 4 Image 5
Component Specifications Role/Use
Raspberry Pi Pico W RP2040 dual-core 133MHz MCU, 264 KB RAM, Wi-Fi module Hosts the MLP model and decision logic; reads sensors; computes irrigation volume.
ESP32 Dual-core 240MHz MCU with Wi-Fi/Bluetooth Receives MQTT commands from Pico; drives the pump relay for irrigation.
Soil Moisture Sensor (Analog) Measures volumetric water content (VWC) in soil/seedling trays Provides real-time soil moisture input for control logic.
Relay Module 5V or 12V signal-controlled relay board Switches power to the water pump under ESP32 control.
Water Pump 12V DC submersible or inline pump (flow rate ~ X L/min) Physically delivers water to the crop (through tubing, emitters, etc.).

Software Stack:

Tool Use
Python (PC) Data handling & model development: pandas, numpy; training with scikit-learn; Jupyter notebooks
MicroPython (Pico) Edge inference & control: Pico W + Thonny; MLP params as arrays; manual matrix ops & activations
ESP32 Firmware MQTT-driven pump control: subscribes to topic; toggles GPIO for relay/pump
Support Tools Thonny for flashing; umqtt.simple for messaging; Jupyter script for model export/deployment

Result: ET₀ Prediction Accuracy

Image 6

Achieved R² ≈ 0.97 on the hold-out test set, meaning the MLP explains 97% of the variance in daily reference evapotranspiration.

Mean Squared Error (MSE) ≈ 0.10 (mm²/day²), indicating low average squared deviation from the FAO-56 ET₀ benchmark.

Image 7 Image 8

Model Efficiency

Original MLP size (weights + biases + scaler stats): ~18 KB

Compressed/pruned deployment size on Pico W: ~12 KB (fits within 264 KB RAM/flash constraints)

Inference time on Pico W: ≤ 50 ms per prediction, enabling real-time daily scheduling.

User interface:

Image 9

Challenges & Mitigations:

Integrating Multiple Sensors

Challenge: Deploying and managing several soil moisture probes, plus environmental sensors, can overload a single microcontroller’s I/O and Wi-Fi bandwidth.

Mitigation:

Use multiple ESP32 nodes, each responsible for a group of sensors.

Aggregate sensor data via Wi-Fi to the Raspberry Pi Pico W, distributing the load and reducing I/O contention.

Sensor Accuracy Drift

Challenge: Capacitive moisture sensors and low-cost environmental probes can drift over time, especially with temperature changes, leading to measurement errors.

Mitigation:

Employ premium, temperature-compensated sensors where possible.

Implement a periodic in-situ recalibration routine

Apply moving-average filters in firmware to smooth out short-term fluctuations and reduce noise.

Microcontroller Resource Constraints

Challenge: The Pico W’s limited flash (264 KB) and RAM require compact model deployment and lean code.

Mitigation:

Prune and quantize the MLP model to reduce its footprint.

Manually implement inference (matrix multiplies and activations) in MicroPython without external ML libraries.

Conclusion:

This project demonstrates a complete Edge AI solution for precision irrigation in nursery crops. By leveraging long-term climate data and an on-device MLP model, the system accurately predicts crop water needs (ETc) in real-time. The integration of crop coefficients (e.g. onion K_c) and soil moisture feedback ensures that watering is neither excessive nor insufficient at any stage. In trials, the Pico W’s MLP inference achieved ~97% accuracy (R²≈0.97) against FAO-56 benchmarks, validating the approach. The edge deployment (MLP code in MicroPython) is lightweight and runs without cloud dependency. Hardware such as the ESP32 pump controller and moisture sensors have been successfully combined with the AI model into a functional prototype.

Moving forward, the system can be extended with a user interface (LCD or app) for monitoring, additional sensors (e.g. temperature probes), or ensemble models for other crops. The modular software and complete documentation on GitHub make it straightforward for technical teams to replicate or customize the system. Overall, this work provides a blueprint for water-efficient, smart irrigation solutions that marry domain knowledge (FAO ET₀, Kc) with modern edge AI techniques.

References:

FAO-56 Penman–Monteith Method

Allen, R. G., Pereira, L. S., Raes, D., & Smith, M. (1998). Crop evapotranspiration: Guidelines for computing crop water requirements. FAO Irrigation and Drainage Paper 56.

NASA POWER API Documentation

NASA Langley Research Center. (n.d.). POWER Data Access Viewer. Retrieved from https://power.larc.nasa.gov/docs/

MLP Regression in Scikit-Learn

Pedregosa, F., Varoquaux, G., Gramfort, A., et al. (2011). Scikit-learn: Machine Learning in Python. Journal of Machine Learning Research, 12, 2825–2830.

Onion Crop Coefficients (Kc)

Allen, R. G., Jensen, M. E., Wright, J. L., & Burman, R. D. (1989). Operational estimates of reference evapotranspiration. Agronomy Journal, 81(4), 650–662.

Edge Deployment & MicroPython

Monk, S. (2019). Programming the Raspberry Pi Pico in MicroPython. The MagPi Magazine.

Espressif Systems. (2021). ESP32 Series Datasheet.

Precision Irrigation and Water Use Efficiency

Jones, H. G. (2004). Irrigation scheduling: advantages and pitfalls of plant-based methods. Journal of Experimental Botany, 55(407), 2427–2436.

Wireless Sensor Networks for Agriculture

Akyildiz, I. F., Su, W., Sankarasubramaniam, Y., & Cayirci, E. (2002). Wireless sensor networks: a survey. Computer Networks, 38(4), 393–422.

Project Repository

AYRUS06. (2025). Edge AI Based Precision Irrigation. GitHub repository. https://github.com/AYRUS06/Edge_AI_based_precision_irrigation